"""
美化结果
"""
import regex as re
import pandas as pd


def drop_zero(num):
    #将数字后无用的0舍去
    nnum = re.split('(?<=\.[0-9]*)0+$',num)[0] 
    return nnum if nnum[-1] != '.' else nnum[:-1]

def prettify_data(data):
    for index in data.index:
        ref_value = data.loc[index,'new_value_ref']
        if not pd.isna(ref_value):
            refList = re.split('([0-9]+\.?[0-9]*)',ref_value)
            refList = [
                drop_zero(part) if re.search('[0-9]+\.?[0-9]*',part) else part
                for part in refList
            ]
            data.loc[index,'new_value_ref'] = ''.join(refList)
        
    return data